﻿using MySql.Data.MySqlClient;
using System;
using System.Data;
using util;
namespace WebApplication1.studentUser
{
    public partial class Liqinshangbao : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        [Obsolete]
        protected void Button1_Click(object sender, EventArgs e)
        {

            //执行
            try
            {
                using (MySqlConnection conn = new MySqlConnection(util.MySqlHelper.ConnStr))
                {
                    conn.Open();
                    string name1 = name.Text;
                    string class_name = classname.Text;
                    string hostel = DropDownList2.SelectedItem.Value;
                    string dormitory = DropDownList1.SelectedItem.Value;
                    string phone = phonenumber.Text;
                    string reason1 = reason.Text;
                    string sql = "insert into out_and_stay_application(name,class_name,hostel,dormitory,reason,phone,type,user_id) values ('" +
                        name1 + "','" + class_name + "','" + hostel + "','" + dormitory + "','" + reason1 + "','" + phone + "','" + 0 + "','" + Application["userId"] + "');";
                    //获得MySsqlCommand
                    MySqlCommand cmd = new MySqlCommand(sql, conn);
                    int result = cmd.ExecuteNonQuery();
                    if (result > 0)
                    {
                        name.Text = " ";
                        classname.Text = " ";
                        phonenumber.Text = " ";
                        reason.Text = " ";
                        this.Page.RegisterStartupScript(" ", "<script>alert(' 申报成功！ '); </script> ");
                    }
                    else
                    {
                        this.Page.RegisterStartupScript(" ", "<script>alert(' 申报失败！ '); </script> ");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}